﻿using System;
using System.Collections.Generic;
using ACompany.OrderProcessing.Model;
using ACompany.OrderProcessing.Presentation;

partial class OrderList : System.Web.UI.Page, IOrderListView
{

    private OrderListPresenter _Presenter;

    protected void Page_Init(object sender, System.EventArgs e)
    {
        _Presenter = new OrderListPresenter(this);
    }

    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            _Presenter.Display();
        }
    }

    public List<Order> Orders
    {
        set
        {
            this.grdOrders.DataSource = value;
            this.grdOrders.DataBind();
        }
    }

    public OrderStatus OrderStatus
    {
        get { return (OrderStatus)Enum.Parse(typeof(OrderStatus), this.ddlOrderStatus.SelectedValue); }
    }

    protected void ddlOrderStatus_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        _Presenter.Display();
    }

    public void ErrorMessage(string Message)
    {
        if (string.IsNullOrEmpty(Message))
        {
            pnlError.Visible = false;
        }
        else
        {
            pnlError.Visible = true;
        }
        this.litErrorMessage.Text = Message.Replace(Environment.NewLine, "<br/>");
    }

    public void InfoMessage(string Message)
    {
        if (string.IsNullOrEmpty(Message))
        {
            pnlInfo.Visible = false;
        }
        else
        {
            pnlInfo.Visible = true;
        }
        this.litInfoMessage.Text = Message.Replace(Environment.NewLine, "<br/>");
    }


    public void ViewTitle(string title)
    {
    }

}